package com.smartjobs.util;

import java.sql.DriverManager;
import java.sql.SQLException;
import com.mysql.jdbc.Connection;


public class DBConnection {

	static Connection con;

	public static Connection getConnection() {
		con = null;
		try {
			Class.forName(RuntimeSettings.driverClass);
			con = (Connection) DriverManager.getConnection(
					RuntimeSettings.dbUrl + RuntimeSettings.databaseName,
					RuntimeSettings.dbUserID, RuntimeSettings.dbPassword);
			MyLog.log("Connection Established");
		} catch (Exception ex) {
			ex.printStackTrace();
			MyLog.log("Could Not Establish Connection");
		}

		return con;
	}

	public void closeConnection() throws SQLException {
		if (con == null) {
			MyLog.log("No Open Connection");
		}

		else {
			con.close();
			MyLog.log("Connection Succesfully Closed");
		}
	}

}
